<template>
    <div>
        <el-page-header title="返回项目首页"
            @back="gotoRoute('/eva-project/setting?name=second&id=' + $route.query.project_id + '&group_type=' + meta.group_type)"
            content="评测表对象人员">
        </el-page-header>
        <el-divider></el-divider>
        <el-radio-group v-model="meta.currentForm" size="small">
            <el-radio-button v-for="(oform) in meta.forms" :key="oform.id" :label="oform" name="owner-form" border>
                {{ oform.name }}
            </el-radio-button>
        </el-radio-group>
        <el-divider></el-divider>
        <div>
            <eva-project-owner-form-user-pager v-if="meta.project_id && meta.project_owner_id && meta.currentForm.id"
                :project_id="meta.project_id" :project_owner_id="meta.project_owner_id"
                :project_owner_form_id="meta.currentForm.id" :user_type="meta.currentForm.type">
            </eva-project-owner-form-user-pager>
        </div>


    </div>
</template>
<script>
import { BaseApi } from '../../../../api/common/base-api';
import EvaProjectOwnerFormUserPager from "./user/Pager.vue";
import { sharedConfig } from '../../../shared/BaseCurd';
const form_api = new BaseApi({ prefix: "/eva-project-owner-form" })
export default {
    name: "EvaProjectOwnerFormUserSetting",
    components: { EvaProjectOwnerFormUserPager },
    data() {
        return {
            meta: {
                project_id: this.$route.query.project_id,
                project_owner_id: this.$route.query.project_owner_id,
                group_type: this.$route.query.group_type,
                currentForm: {},
                forms: [],
            }
        }
    },
    async mounted() {
        const { data } = await form_api.findList({
            where: {
                project_id: this.meta.project_id,
                project_owner_id: this.meta.project_owner_id
            }
        });
        //这里只有这三个表可以设置被测评人员，其他表都是整体测评
        this.meta.forms = data.filter(r => r.user_type >= 0 && r.user_type < 3).map(({ ru_form_id, ru_form_name, user_type }) => ({ id: ru_form_id, name: ru_form_name, type: user_type }));
        if (this.meta.forms.length > 0) {
            this.meta.currentForm = this.meta.forms[0];
        }
    },
    methods: {
        ...sharedConfig.methods,
        onSelectForm(value) {
            //console.log(value);
        }
    }
}
</script>